<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PDF转换器</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <style>
        /* 自定义样式，可根据需要调整 */
        .custom-file-input ~ .custom-file-label::after {
            content: "选择文件";
        }
        .operation-card {
            border: 1px solid #dee2e6;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container mt-5">
        <h1 class="text-center mb-4">PDF格式转换工具</h1>
        
        <!-- 功能选择区域 -->
        <div class="operation-card">
            <form id="mergeForm" enctype="multipart/form-data">
                <div class="form-group">
                    <h4>请选择操作类型：</h4>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="operationType" 
                               id="mergeOperation" value="merge" checked>
                        <label class="form-check-label" for="mergeOperation">PDF合并</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="operationType" 
                               id="convertOperation" value="convert">
                        <label class="form-check-label" for="convertOperation">PDF转Word</label>
                    </div>
                </div>

                <!-- PDF合并文件上传 -->
                <div class="form-group" id="pdfUploadGroup">
                    <label for="pdfFiles">选择要合并的PDF文件（可多选）：</label>
                    <div class="custom-file">
                        <input type="file" class="custom-file-input" id="pdfFiles" 
                               name="pdfFiles" multiple accept=".pdf">
                        <label class="custom-file-label" for="pdfFiles">选择2个或多个文件</label>
                    </div>
                </div>

                <!-- PDF转Word文件上传 -->
                <div class="form-group" id="convertUploadGroup" style="display: none;">
                    <label for="convertFile">选择要转换的PDF文件：</label>
                    <div class="custom-file">
                        <input type="file" class="custom-file-input" id="convertFile" 
                               name="pdfFile" accept=".pdf">
                        <label class="custom-file-label" for="convertFile">选择单个文件</label>
                    </div>
                </div>

                <!-- 输出文件名 -->
                <div class="form-group">
                    <label for="outputFilename" id="filenameLabel">输出文件名：</label>
                    <input type="text" class="form-control" id="outputFilename" 
                           name="outputFilename" placeholder="merged.pdf" 
                           value="merged.pdf">
                </div>

                <button type="submit" class="btn btn-primary btn-block">开始处理</button>
                <p id="status" class="mt-3 text-center"></p>
            </form>
        </div>

        <!-- 使用说明 -->
        <div class="operation-card">
            <h4>使用说明</h4>
            <div id="mergeInstructions">
                <p>1. 选择多个PDF文件进行合并</p>
                <p>2. 输入合并后的文件名（默认：merged.pdf）</p>
                <p>3. 点击"开始处理"按钮</p>
            </div>
            <div id="convertInstructions" style="display: none;">
                <p>1. 选择单个PDF文件进行转换</p>
                <p>2. 输入转换后的文件名（默认：converted.docx）</p>
                <p>3. 点击"开始处理"按钮</p>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="static/main.js"></script>
</body>
</html>